<template>
  <base-dialog title="日志详情" ref="baseDialog" :btnShow="false" width="42%">
    <el-form ref="form" disabled :model="form" label-width="125px" size="mini">
      <el-row>
        <el-col :span="24">
          <el-form-item label="日志主键：">{{ form.id }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="机器人渠道：">
            {{ form.channelCode }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="机器人名称：">
            {{ form.channelId }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="消息模板：">
            {{ form.templateId }} | {{ form.templateCode }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="模板类型：">{{ form.templateType }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="消息内容：">{{ form.templateContent }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="消息参数：">{{ form.templateParams }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="创建时间：">{{ form.createTime }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="发送状态：">{{ form.sendStatus }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="发送时间：">{{ form.sendTime }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="发送结果：">{{ form.sendCode }} | {{ form.sendMsg }}</el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </base-dialog>
</template>

<script>
export default {
  name: "Dialog",
  props: {
    typeList: {
      default: () => [],
      type: Array
    },
    channelList: {
      default: () => [],
      type: Array
    },
    sendStatusList: {
      default: () => [],
      type: Array
    },
    receiveStatusList: {
      default: () => [],
      type: Array
    }
  },
  data() {
    return {
      form: {},
      codeList: []
    }
  },
  created() {
    this.codeList = this.$store.getters.dictList(this.$DICT_TYPE.ROBOT_CHANNEL_CODE)
  },
  methods: {
    init(item) {
      this.$refs.baseDialog.dialogVisible = true
      if (item) {
        this.form = JSON.parse(JSON.stringify(item))
        this.form.sendStatus = this.sendStatusList.find(
          (item) => item.value == this.form.sendStatus
        )?.label
        this.form.receiveStatus = this.receiveStatusList.find(
          (item) => item.value == this.form.receiveStatus
        )?.label
        this.form.channelId = this.channelList.find((item) => item.id == this.form.channelId)?.name
        this.form.templateType = this.typeList.find(
          (item) => item.id == this.form.templateType
        )?.label
        this.form.channelCode = this.codeList.find(
          (item) => item.value == this.form.channelCode
        )?.label
      }
    },
    handleClose() {
      this.$refs.baseDialog.dialogVisible = false
      this.title = ""
    }
  }
}
</script>

<style lang="scss" scoped>
.el-select,
.picker,
.el-input-number {
  width: 100%;
}
</style>
